package com.order.service.impl;

import com.aaa.entity.TOrder;
import com.aaa.entity.TProduct;
import com.order.feign.ProductFeign;
import com.order.mapper.TOrderMapper;
import com.order.service.ITOrderService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 于永利
 * @since 2023-07-20
 */
@Service
public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> implements ITOrderService {

    // 引入
    @Resource
    private ProductFeign productFeign;

    @Override
    public Boolean addOrder(Integer id) {
        //1. 查询一下商品的价格
        TOrder order = new TOrder();
        order.setUid(1);
        order.setNum(100);
        order.setPid(id);
        // 价格  通过product
        TProduct byProId = productFeign.getByProId(id);
        order.setProprice(byProId.getPrice());
        // 添加  订单
        boolean save = this.save(order);

        return save;
    }
}
